<?php
/**
 * 微博后台管理项目 媒体表数据层

 */
define("CACHE_MBLOG_COUNT_TUIJIAN_MBLOG","tuijian_mblog_");
class db_tuijian_mblog extends db_base
{
	var $table_name  ="tuijian_mblog";
	
	
	/**
	 * 根据D_ID取数据
	 * @param $d_id
	 */
	function get_list_by_order($show_type=1,$p=1,$pcount=10)
	{
		$key = CACHE_MBLOG_COUNT_TUIJIAN_MBLOG . "-get_list_by_order-{$show_type}-{$p}-{$count}";
		$mc = mem_cache::get_instance();
		$cache = $mc->get($key);
		if ($cache === false)
		{
			if($show_type)
			{
				$where = "show_type ={$show_type}  and status =1  ";
				
			}
			else
			{
				
				$where = " status =1  ";
			}
			$content = $this->get_alllist($this->table_name,$p,$pcount, " `create_time` desc ", $where);
			$mc->set($key, serialize($content), 0, CACHE_EXPIRE_MIN_10);
		}
		else
		{
			$content = unserialize($cache);
		}

		return $content;
	}
	
	
	
	
	function admin_get_list($status,$show_type=1,$p=1,$pcount=10)
	{
		
		if($show_type)$where_array[] = " show_type ={$show_type} ";
		if(strlen($status)>0)$where_array[] = " status ={$status} ";
		
			
		$where = join(" and ",	$where_array);
		
		$content = $this->get_alllist($this->table_name,$p,$count, " `create_time` desc", $where);
	

		return $content;
	}
	
	function admin_get_count($status,$show_type=1)
	{
		
		if($show_type)$where_array[] = " show_type ={$show_type} ";
		if(strlen($status)>0)$where_array[] = " status ={$status} ";
		
			
		$where = join(" and ",	$where_array);
		
		$content = $this->get_listcount($this->table_name,$where);
	

		return $content;
	}
	
	
	function admin_update_by_id($id,$status="")
	{
		$where = "mblog_id = $id";
		
		if(strlen($status)>0)$ary["status"] = $status;
		
		return $this->update($this->table_name,$ary,$where);
	}
	
	
	function admin_insert_tuijian_mblog($show_type,$mblog_id,$order,$uid,$detail_info)
	{
		$ary["uid"] = $uid;
		$ary["show_type"] = $show_type;
		$ary["order"] = $order;
		$ary["mblog_id"] = $mblog_id;
		$ary["detail_info"] = $detail_info;
		$ary["status"] = 1;
		$ary["create_time"] = Date::get_date_time();
		$ary["create_ip"] = IP::get_client_ip_long();
	
		$res = $this->insert($this->table_name,$ary,"",true);
		
		return $res;
		
	}
	
	function cron_insert_tuijian_mblog($show_type,$mblog_id,$order,$uid,$detail_info)
	{
		$ary["uid"] = $uid;
		$ary["show_type"] = $show_type;
		$ary["order"] = $order;
		$ary["mblog_id"] = $mblog_id;
		$ary["detail_info"] = $detail_info;
		$ary["status"] = 1;
		$ary["is_tuijian"] = 1;
		$ary["create_time"] = Date::get_date_time();
		$ary["create_ip"] = IP::get_client_ip_long();
	
		$res = $this->insert($this->table_name,$ary,"",true);
		
		return $res;
		
	}
	
	
	function cron_del_tuijian_mblog()
	{
		$ary["order"] = "100";
		$res = $this->update($this->table_name,$ary,$where);
		return $res;
		
	}
}
